var Clock = require('geoClockBase');
var Utils = require('geoUtils');


cc.Class({
    extends: cc.Component,

    properties: {
        hours:0,
        minutes:0,
        seconds:0,
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this.clocks = Utils.node.getComponentsInHierarchy(cc.director.getScene(), Clock);
    },

    onHourSlider(e){
        this.hours = Math.ceil(e.progress * 23);
        //
        this.updateClocks();
    },
    onSecondSlider(e){
        this.seconds = Math.ceil(e.progress * 59);
        //
        this.updateClocks();
    },
    onMinuteSlider(e){
        this.minutes = Math.ceil(e.progress * 59);
        //
        this.updateClocks();
    },

    updateClocks(){
        this.clocks.forEach(clock => {
            clock.setTime(this.hours, this.minutes, this.seconds, null);
        });
    }



    // update (dt) {},
});
